#include "biaoge.h"
#include "ui_biaoge.h"
#include "QPainter"
#include "math.h"
biaoge::biaoge(QWidget *parent) :
    QMainWindow(parent)//,
   // ui(new Ui::biaoge)
{
    resize(500,500);
    int i=0;
    //ui->setupUi(this);
    for(i=0;i<11;i++)
    {
        b[i]=30*i;
        a[i]=rand()%100;
    }
    this->startTimer(600);
}

biaoge::~biaoge()
{

    //delete ui;
}
void biaoge::timerEvent(QTimerEvent *)
{
    int i=0;
    for(i=0;i<10;i++)
    {
        //b[i]=30*i;
        a[i]=a[i+1];
    }
    srand((unsigned)time(NULL));
    a[10]=rand()%100;
    this->repaint();
}
void biaoge::paintEvent(QPaintEvent *)
{
    int i,m=0,n=0,y=0;
    //a[15]={0};
    //b[15]={0};
    QPainter painter(this);
    QPen pen(Qt::DotLine);
    painter.drawLine(0,300,0,0);
    painter.drawLine(0,300,300,300);
    painter.setPen(pen);

    //srand((unsigned)time(NULL));

    for(i=0;i<10;i++)
    {
        painter.drawLine(m,0,m,300);
       m=30+m;
    }
    for(i=0;i<10;i++)
    {
        painter.drawLine(300,n,0,n);
        n=n+30;
    }
    pen.setStyle(Qt::SolidLine);
    pen.setColor(QColor(255,0,0,255));
    painter.setPen(pen);
    /*for(i=0;i<10;i++)
    {
        b[i]=30*i;
         a[i]=rand()%100;
    }*/
    for(i=0;i<10;i++)
    {

        painter.drawLine(b[i],a[i],b[i+1],a[i+1]);
    }
}
